package dao.impl;

import dao.DeptDao;
import org.apache.ibatis.session.SqlSession;
import pojo.Dept;
import util.MyBatisUtil;

import java.util.List;

public class DeptDaoImpl implements DeptDao {

    @Override
    public List<Dept> findAll(Dept user) {
        return MyBatisUtil.getSession().getMapper(DeptDao.class).findAll(user);
    }

    @Override
    public int addUser(Dept user) {
        SqlSession session = MyBatisUtil.getSession();
        int result = session.getMapper(DeptDao.class).addUser(user);
        session.commit();
        return result;
    }


    @Override
    public int updateUser(Dept user) {
        SqlSession session = MyBatisUtil.getSession();
        int result = session.getMapper(DeptDao.class).updateUser(user);
        session.commit();
        return result;
    }

    @Override
    public int deleteUserById(int id) {
        SqlSession session = MyBatisUtil.getSession();
        int result = session.getMapper(DeptDao.class).deleteUserById(id);
        session.commit();
        return result;
    }

    @Override
    public Dept findUserById(int id) {
        return MyBatisUtil.getSession().getMapper(DeptDao.class).findUserById(id);
    }

}

